<?php
class SessionBase{
	public static function setSession($rootKey, $key, $value)
	{
		if (is_object($value))
		{
			$value = serialize($value);
		}
		$_SESSION[$rootKey][$key] = $value;
	}

	public static function getSession($rootKey, $key)
	{
		return isset($_SESSION[$rootKey][$key]) ? $_SESSION[$rootKey][$key] : FALSE;
	}

	public static function getObjectSession($rootKey, $key)
	{
		if (isset($_SESSION[$rootKey][$key]))
		{
			return unserialize($_SESSION[$rootKey][$key]);
		}
		return FALSE;
	}

	public static function clearSession($rootKey, $key = FALSE)
	{
		if ($key)
		{
		    if(isset($_SESSION[$rootKey][$key])){
		        unset($_SESSION[$rootKey][$key]);
		    }
		}
		else
		{
			unset($_SESSION[$rootKey]);
		}
	}

}